package com.springbootdemo.demo.controller;

import com.battcn.swagger.properties.ApiDataType;
import com.battcn.swagger.properties.ApiParamType;
import com.springbootdemo.demo.bean.Book;
import com.springbootdemo.demo.bean.User;
import com.springbootdemo.demo.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("users")
@Api(tags = "1.1", description = "用户管理", value = "用户管理")
public class SwaggerController {

    /**
     * http://localhost:8080/swagger-ui.html   swagger调试页面
     */

    private static final Logger log = LoggerFactory.getLogger(SwaggerController.class);

    @Autowired
    private IUserService userService;


    /**
     * swagger测试
     * @param id
     * @return
     */
    @RequestMapping("queryByCondition")
    @ResponseBody
    @ApiOperation(value = "条件查询（DONE）")
    public User queryByCondition(String id) {
        log.info("多个参数用  @ApiImplicitParams");
        return userService.get("1");
    }


    /**
     * 校验数据合法性
     * @param book
     * @return
     */
    @GetMapping("book")
    @ResponseBody
    @ApiOperation(value = "校验数据合法性")
    public boolean validateBook(@Validated Book book){
        return true;
    }


}
